package com.ruoyi.web.controller.memberManagement;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MemberSettingOperationLog;
import com.ruoyi.system.service.IMemberSettingOperationLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员设置操作记录（存储会员系统配置变更的历史记录）Controller
 *
 * @author ruoyi
 * @date 2025-05-20
 */
@Api(tags="会员设置操作记录")
@RestController
@RequestMapping("/system/memberSettingOperationLog")
public class MemberSettingOperationLogController extends BaseController
{
    @Autowired
    private IMemberSettingOperationLogService memberSettingOperationLogService;

    /**
     * 查询会员设置操作记录列表
     */
    @ApiOperation("查询会员设置操作记录列表")
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String operationType, @RequestParam(required = false) Date operationStartTime, @RequestParam(required = false) Date operationEndTime)
    {
        startPage();
        List<MemberSettingOperationLog> list = memberSettingOperationLogService.selectMemberSettingOperationLogListByConditions(operationType,operationStartTime,operationEndTime);
        return getDataTable(list);
    }

    /**
     * 导出会员设置操作记录列表
     */
    @ApiOperation("导出会员设置操作记录列表")
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "会员设置操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestParam(required = false) String operationType, @RequestParam(required = false) Date operationStartTime, @RequestParam(required = false) Date operationEndTime)
    {
        List<MemberSettingOperationLog> list = memberSettingOperationLogService.selectMemberSettingOperationLogListByConditions(operationType,operationStartTime,operationEndTime);
        ExcelUtil<MemberSettingOperationLog> util = new ExcelUtil<MemberSettingOperationLog>(MemberSettingOperationLog.class);
        util.exportExcel(response, list, "会员设置操作记录数据");
    }

    /**
     * 通过id获取会员设置操作记录详细信息
     */
    @ApiOperation("通过id获取会员设置操作记录详细信息")
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(memberSettingOperationLogService.selectMemberSettingOperationLogById(id));
    }

    /**
     * 新增会员设置操作记录
     */
    @ApiOperation("新增会员设置操作记录")
    @PreAuthorize("@ss.hasPermi('system:log:add')")
    @Log(title = "会员设置操作记录（存储会员系统配置变更的历史记录）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberSettingOperationLog memberSettingOperationLog)
    {
        return toAjax(memberSettingOperationLogService.insertMemberSettingOperationLog(memberSettingOperationLog));
    }

    /**
     * 修改会员设置操作记录
     */
    @ApiOperation("修改会员设置操作记录")
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "会员设置操作记录（存储会员系统配置变更的历史记录）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberSettingOperationLog memberSettingOperationLog)
    {
        return toAjax(memberSettingOperationLogService.updateMemberSettingOperationLog(memberSettingOperationLog));
    }

    /**
     * 通过id批量删除会员设置操作记录
     */
    @ApiOperation("通过id批量删除会员设置操作记录")
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "会员设置操作记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memberSettingOperationLogService.deleteMemberSettingOperationLogByIds(ids));
    }
}
